fn match_literals() {
    let x = Some(5);
    let y = 10;
    match x {
        Some(50) => println!("这个some50"),
        Some(y) => println!("获取some({})中的值", y),
        _ => println!("什么都没有欸"),
    }
}
struct Point {
    x: i32,
    y: i32,
}
fn deconstruction() {
    let p = Point { x: 0, y: 7 };
    match p {
        Point { x, y: 0 } => println!("在x轴上({})", x),
        Point { x: 0, y } => println!("在y轴上({})", y),
        Point { x, y } => println!("在y,x轴上({},{})", x, y),
    }
}
enum Color {
    Rgb(i32, i32, i32),
    Hsv(i32, i32, i32),
}
enum Message {
    Quit,
    Move { x: i32, y: i32 },
    Write(String),
    ChangeColor(Color),
}
fn match_color() {
    let msg = Message::ChangeColor(Color::Rgb(33, 33, 33));

    match msg {
        Message::ChangeColor(Color::Rgb(x, y, z)) => {
            println!("RGB颜色为({},{},{})", x, y, z)
        }
        Message::ChangeColor(Color::Hsv(x, y, z)) => {
            println!("Hsv颜色为({},{},{})", x, y, z)
        }
        _ => {}
    }
}
fn foo(_: i32, y: i32) {
    println!("This code only uses the y parameter: {}", y);
}
fn match_bind() {
    enum Message {
        Hello { id: i32 },
    }
    let msg = Message::Hello { id: 5 };
    match msg {
        Message::Hello { id: _id @ 3..7 } => println!("_id{}", _id),
        Message::Hello { id: _id @ 10..12 } => println!("_id{}", _id),
        Message::Hello { id } => {
            println!("Found some other id: {}", id)
        }
    }
}
fn main() {
    match_literals();
    match_color();
    deconstruction();
    let ((a, b), Point { x, y }) = ((1, 2), Point { x: 1, y: 2 });
    println!("a:{},b:{},x:{},y:{}", a, b, x, y);
    foo(0, 5);
    match_bind();
}
